package com.googlecode.ddplan.dwr.domain;

import com.googlecode.ddplan.PDDLName;
import com.googlecode.ddplan.PDDLState;
import com.googlecode.ddplan.PDDLType;

@PDDLType
public class Pile {
	@PDDLName
	private String name;

	private Integer number;
	private Box pallet;

	public Pile(String name, int number) {
		this.name = name;
		this.number = number;
		pallet = new Box("pallet_" + name);
	}

	public Integer getNumber() {
		return number;
	}

	public boolean contains(Box box) {
		Box iteratingBox = pallet;
		while (iteratingBox.hasUpper()) {
			iteratingBox = iteratingBox.getUpperBox();
			if (iteratingBox.equals(box)) {
				return true;
			}
		}
		return false;
	}

	@PDDLState
	public boolean attached(Location location) {
		return location.hasPile(this);
	}

}
